﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using DataAccess.Language;
namespace Bussiness.Language
{
    public class LanguageBLL
    {
        private LanguageDAL dal;
        public LanguageBLL()
        {
            dal = new LanguageDAL();
        }
        public FOModels.Language.Language getLangByCode(string code)
        {
            FOModels.Language.Language lang = null;
            DataTable tb = dal.getLangByCode(code);
            if (tb != null && tb.Rows.Count > 0)
            {
                lang = new FOModels.Language.Language();
                lang.Enable = bool.Parse( tb.Rows[0]["Enable"].ToString());
                lang.FlagImage = tb.Rows[0]["FlagImage"].ToString();
                lang.LangCode = tb.Rows[0]["LanguageCode"].ToString();
                lang.LangID =int.Parse( tb.Rows[0]["ID"].ToString());
                lang.MonneyUnit = tb.Rows[0]["MoneyUnit"].ToString();
                lang.Name = tb.Rows[0]["Name"].ToString(); 
            }
            return lang;
        }
        public List<FOModels.Language.Language> getActiveLang()
        {
            List<FOModels.Language.Language> list = new List<FOModels.Language.Language>();
            DataTable tb = dal.getActiveLang();
            FOModels.Language.Language lang;
            if (tb != null && tb.Rows.Count > 0)
            {
                foreach (DataRow rw in tb.Rows)
                {
                    lang = new FOModels.Language.Language();
                    lang.Enable=bool.Parse(rw[2].ToString());
                    lang.FlagImage = rw[3].ToString();
                    lang.LangCode = rw[5].ToString();
                    lang.LangID =int.Parse( rw[0].ToString());
                    lang.MonneyUnit = rw[4].ToString();
                    lang.Name = rw[1].ToString();
                    list.Add(lang);
                }
            }
            return list;
        }
    }
}
